package xyz.xpman.prisonerfitness.kit;

import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.MenuItem;
import android.widget.ImageButton;

import androidx.annotation.RequiresApi;

public enum ColorKit {;

    public static void setColorFilter(final MenuItem item, final int color) {
        // 下面两行可提取出来，优化性能
        final Drawable itemIcon = item.getIcon();
        itemIcon.mutate();

        itemIcon.setColorFilter(color, PorterDuff.Mode.SRC_IN);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public static void setColorFilter(final ImageButton item, final int color) {
        item.getBackground().setTint(color);
    }

}
